package org.easy.minimaxi.modle;

public enum MinimaxErrorCode {
    SUCCESS(0, "请求成功"),
    RATE_LIMITED(1002, "触发限流，请稍后再试"),
    AUTHENTICATION_FAILED(1004, "账号鉴权失败，请检查 API-Key 是否填写正确"),
    INSUFFICIENT_BALANCE(1008, "账号余额不足"),
    SENSITIVE_CONTENT(1026, "视频描述涉及敏感内容，请调整"),
    INVALID_PARAMETER(2013, "传入参数异常，请检查入参是否按要求填写"),
    INVALID_API_KEY(2049, "无效的api key，请检查api key");

    private final int code;
    private final String message;

    MinimaxErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static MinimaxErrorCode getByCode(int code) {
        for (MinimaxErrorCode errorCode : values()) {
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }
        return null;
    }
}